/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __LIB2D_GUI_DIALOG_H__
#define __LIB2D_GUI_DIALOG_H__

#include "Object.h"
#include "Button.h"
#include <xml/Object.h>
#include "view/Dialog.h"

namespace liba
{
namespace lib2d
{
namespace gui
{

class Dialog;

namespace dialog
{
class CloseButton : public Button
{
	Dialog * parent;
public:
	CloseButton( Dialog * parent );
	virtual void on_button_up( const Vector2 & point, const Atom & button_name );
	void layout();
};
}

class Dialog :
	public Object,
	public xml::ObjectANSI
{
	AutoPtr< dialog::CloseButton > close_button;

	Vector2 mouse_pos;
	bool mouse_catched;

	AutoPtr< view::Dialog > view;
	friend class view::Dialog;

	void track_mouse_move( const Vector2 & point );
public:
	Dialog( Object * parent );

	virtual view::Dialog * get_view()const
	{
		return view;
	}

	virtual bool on_attribute( xml::Provider * prov, const std::string & name, const std::string & value );
	virtual bool on_node( xml::Provider * prov, const std::string & name );

	void on_close();

	virtual void on_button_down( const Vector2 & point, const Atom & button_name );
	virtual void on_button_up( const Vector2 & point, const Atom & button_name );
	virtual void on_mouse_move_outside( const Vector2 & point );
	virtual void on_mouse_move( const Vector2 & point );
};

} //namespace gui
} //namespace lib2d
} //namespace liba

using namespace liba;

#endif //__LIB2D_GUI_DIALOG_H__
